
//
//  TSView.m
//  Review-Objective-C
//
//  Created by mac on 2017/7/18.
//  Copyright © 2017年 com.qiankun. All rights reserved.
//

#import "TSView.h"

@implementation TSView

/*
 // Only override drawRect: if you perform custom drawing.
 // An empty implementation adversely affects performance during animation.
 - (void)drawRect:(CGRect)rect {
 // Drawing code
 }
 */

//重写初始化方法
- (instancetype)init
{
    self = [super init];
    if (self) {
        
        //        [self addimg];
        
        
    }
    return self;
}



-(void)addimg
{
    
    UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(100, 100, 100, 100)];
    [self addSubview:imageView];
    
    //    设置背景颜色。注意UIColor 和 CGColor之间的互换
    imageView.layer.backgroundColor = [UIColor grayColor].CGColor;
    
    //    生成一个path
    UIBezierPath *path = [UIBezierPath bezierPathWithRect:CGRectMake(-10, -10, imageView.bounds.size.width + 20, imageView.bounds.size.height + 20)];
    //    设置阴影path
    imageView.layer.shadowPath = path.CGPath;
    
    //    设置阴影颜色
    imageView.layer.shadowColor = [UIColor lightGrayColor].CGColor;
    
    //    设置阴影透明度
    imageView.layer.shadowOpacity = 0.5;
    
}
@end
